﻿using System;
using System.Text.RegularExpressions;

namespace ExtractTriplesFromtText
{
    class ExtractTriplesFromtText
    {
        static void Main(string[] args)
        {
            string patter = @"\(-?[1-9][0-9]*,\s?-?[1-9][0-9]*,\s?-?[1-9][0-9]*\)";
            string text = "This is a list of triples: (1, -2, -3); (22,33,44) and (1,2,3). This is not a triple: (1,2)." +
                "This is also not a triple: [1,2,3]. Not that this is triple: ( 1, 2, 3 ).";

            Match matches = Regex.Match(text, patter);

            while (matches.Success) 
            {
                Console.WriteLine("{0} {1}",matches,matches.Index);
                matches = matches.NextMatch();
            }
        }
    }
}
